import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Index from '@/views/Index.vue'
import Settings from '@/views/Settings.vue'
import Home from '@/views/Home.vue'
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Index',
    component: Index
  },
  {
    path: '/home',
    name: 'Home',
    meta: { title: '主页' },
    component: Home
  },
  {
    path: '/settings',
    name: 'Settings',
    meta: { title: '设置' },
    component: Settings
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})
router.beforeEach((to: any, from: any) => {
  if (to.meta?.title) {
    document.title = to.meta.title
  }
})

export default router
